import {request} from "@/utils";


// 获取频道列表
function getChannelsAPI(  ){
    return request({
        method: 'get',
        url: '/channels'
    })
}

// 发布文章
function createArticleAPI( fromData ){
    return request({
        method: 'post',
        url: '/mp/articles?draft=false',
        data:fromData
    })
}

// 获取文章列表
function getArticlesAPI( params ){
    return request({
        method: 'get',
        url: '/mp/articles',
        params
    })
}

function delArticlesAPI( data ){
    return request({
        method: 'delete',
        url: `/mp/articles/${data.id}`
    })
}


// 获取文章详情
function getArticleById (id) {
    return request({
        method: 'get',
        url: `/mp/articles/${id}`
    })
}

// 更新文章表单
function updateArticleAPI (data) {
    return request({
        url: `/mp/articles/${data.id}?draft=false`,
        method: 'PUT',
        data
    })
}


export {createArticleAPI,getChannelsAPI,getArticlesAPI,delArticlesAPI,getArticleById,updateArticleAPI}